package cn.tedu.egmvcboot1.common.interceptors;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckLoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response,Object handler) throws Exception{
        if(request.getSession().getAttribute("user")==null){
            response.sendRedirect("/index.html");
            return false;
        }
        return true;
    }
}
